package com.momo.hr.exception;

import com.momo.hr.bean.RespBean;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.sql.SQLIntegrityConstraintViolationException;


/**
 * 全局的统一异常处理
 */
@RestControllerAdvice
public class GlobalExceptionHandler {

    /**
     * 数据库外键关联的异常处理
     * @return RespBean
     */
    @ExceptionHandler(value = SQLIntegrityConstraintViolationException.class)
    public RespBean deletePosError(SQLIntegrityConstraintViolationException e){
            return RespBean.error("删除失败,该项存在关联项目。请先处理");
    }


}
